package pl.edu.agh.intobl;

/**
 * @author Gosia
 *
 */
public class Customer {

	final int id;
	final int x;
	final int y;
	final int demand;
	final int readyTime;
	final int dueDate;
	final int label;
	final int serviceTime;


	/**
	 * @param id - sequence number, starting with 0
	 * @param label - most cases - id + 1, should be consistent with customer Id from the configuration file.
	 * @param x - X coordinate
	 * @param y - Y coordinate
	 * @param demand
	 * @param readyTime - for TW
	 * @param dueDate - for TW
	 * @param serviceTime - for TW
	 */
	public Customer(int id, int label, int x, int y, int demand,
			int readyTime, int dueDate, int serviceTime) {
		super();
		this.id = id;
		this.label = label;
		this.x = x;
		this.y = y;
		this.demand = demand;
		this.readyTime = readyTime;
		this.dueDate = dueDate;
		this.serviceTime = serviceTime;
	}

	public int getId() {
		return id;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public int getDemand() {
		return demand;
	}

	public int getReadyTime() {
		return readyTime;
	}

	public int getDueDate() {
		return dueDate;
	}

	public int getServiceTime() {
		return serviceTime;
	}


	/**
	 * @param anotherCustomer
	 * @return distance computed as Euclidean distance: distance = sqrt((x1-x2)**2  + (y1-y2)**2)
	 */
	public double getDistanceFromAnotherCustomer(Customer anotherCustomer) {
		int deltaX = this.x - anotherCustomer.getX();
		int deltaY = this.y - anotherCustomer.getY();
		int sum = deltaX*deltaX + deltaY*deltaY;
		Double distance = Math.sqrt(sum);
		return distance;
	}

	public int getLabel() {
		return label;
	}
	
	@Override
	public String toString() {
		return String.valueOf(label);
	}

}
